package gov.dhs.cis.soa.data;

import gov.dhs.cis.soa.Constants;
import gov.dhs.cis.soa.Utils;
import gov.dhs.cis.soa.Constants.EntityType;

public class Agent extends AbstractSOAData {
	public static final String STEREO_TYPE = "Agent";
	public static final String ENT_SERV_STEREO_TYPE = "Enterprise Service";
	
	public int id;

	public String name;
	public String release;
	public transient String descText;
	public String stereoType;
	public String dataInit;
	public String dataResp;
	public String connExtApp;
	public String connExtComp;
	public String placement;
	public transient String owner;
	public String existence;
	public transient String designAspects;
	public transient String mep;
	public transient String securityAspects;
	public Description desc;
	
	@Override
	public String toString() {
		return "Agent [id=" + id + ", name = " + name + ", stereotype=" + stereoType + "]";
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Agent other = (Agent) obj;
		if (id == other.id && name.equalsIgnoreCase(other.name))
			return true;
		return false;
	}	

	public void createDescription() {
		StringBuffer txt = new StringBuffer();
		if (Utils.isEmpty(descText))
			descText = "";
		txt.append(Constants.NL + "Documentation = " + descText);
		if (Utils.isEmpty(owner))
			owner = "";
		txt.append(Constants.NL + "Development Owner = " + owner);
		if (Utils.isEmpty(designAspects))
			designAspects = "";
		txt.append(Constants.NL + "Design Aspects = " + designAspects);
		if (Utils.isEmpty(mep))
			mep = "";
		txt.append(Constants.NL + "Message Exchange Patterns Supported = " + mep);
		if (Utils.isEmpty(securityAspects))
			securityAspects = "";
		txt.append(Constants.NL + "Security Aspects = " + securityAspects);
				
		desc = Utils.prepareDescObj(txt.toString(), EntityType.AGNT);
	}
	
//	public static String getUMLId(int entityId) {
//		return EntityType.AGNT + "_" + entityId;
//	}

	@Override
	public long getId() {
		return id;
	}
	@Override
	public String getHashableId() {
		return name;
	}
	@Override
	public EntityType getUMLType() {
		return EntityType.AGNT;
	}
}
